
{% extends "RihabBundle::layout.html.twig" %}
{% block titre %} Enseignant{% endblock %}
{% block css %}
    {{parent()}}
    <link rel="stylesheet" href="/js/vendor/datepicker/css/bootstrap-datetimepicker.css">
    <link rel="stylesheet" href="/js/vendor/chosen/css/chosen.min.css">
    <link rel="stylesheet" href="/js/vendor/chosen/css/chosen-bootstrap.css">
{% endblock %}
{% block body %}
    <div class="main">
        <div class="row">
            <div id="form-type" class="col-md-12">

                <section class="tile color transparent-black">
                    <div class="tile-header">
                        <h1><strong>{% if id =='' %}Nouveau {% else %}Modifier {% endif %}</strong> Enseignant</h1>
                        <div class="controls">
                            <a class="refresh" href="#"><i class="fa fa-refresh"></i></a>
                            <a class="remove" href="#"><i class="fa fa-times"></i></a>
                        </div>
                    </div>
                    <div class="tile-body">
                        <form id="form-Enseignant" action="{{path('stage_enseignant_new')}}" method="post" class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-4 control-label" for="input01">Nom</label>
                                <div class="col-sm-8">
                                    {{form_widget(form.nom,{'attr':{'class':'form-control'}})}}{{form_widget(form._token)}}
                                    <input type="hidden" value="{{id}}" name="id" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label" for="input01">Prénom</label>
                                <div class="col-sm-8">
                                    {{form_widget(form.prenom,{'attr':{'class':'form-control'}})}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label" for="input01">Date De Naissance</label>
                                <div class="col-sm-8">
                                    {{form_widget(form.dateNaissance,{'attr':{'class':'form-control'}})}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label" for="input01">N°Cin</label>
                                <div class="col-sm-8">
                                    {{form_widget(form.cin,{'attr':{'class':'form-control'}})}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label" for="input01">N°Télèphone</label>
                                <div class="col-sm-8">
                                    {{form_widget(form.telephonne,{'attr':{'class':'form-control'}})}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label" for="input01">E-mail</label>
                                <div class="col-sm-8">
                                    {{form_widget(form.email,{'attr':{'class':'form-control'}})}}
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-4 control-label" for="input01">Mot de passe</label>
                                <div class="col-sm-8">
                                    {{form_widget(form.plainPassword.first,{'attr':{'class':'form-control'}})}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label" for="input01">Confirmer le mot de passe</label>
                                <div class="col-sm-8">
                                    {{form_widget(form.plainPassword.second,{'attr':{'class':'form-control'}})}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label" for="input01">Login</label>
                                <div class="col-sm-8">
                                    {{form_widget(form.username,{'attr':{'class':'form-control'}})}}
                                </div>
                            </div>

                            <div class="form-group form-footer">
                                <div class="col-sm-offset-4 col-sm-8">
                                    <button class="btn btn-primary" type="submit" >Enregistrer</button>
                                    <button class="btn btn-default" type="reset">Effacer</button>
                                </div>
                            </div>

                        </form>

                    </div>
                </section>
            </div>
        </div>
    </div>

{% endblock %}

{% block js %}
    {{parent()}}
    <script src="/js/vendor/momentjs/moment-with-langs.min.js"></script>
    <script src="/js/vendor/datepicker/bootstrap-datetimepicker.min.js"></script>
    <script src="/js/jquery.validate.js"></script>
    <script>

        $('#form-Enseignant').validate({
            rules: {
                "stage_stagebundle_enseignant[nom]": {
                    required: true,
                    minlength: 3,
                    maxlength: 50
                },
                "stage_stagebundle_enseignant[prenom]": {
                    required: true,
                    minlength: 3,
                    maxlength: 50

                },
                "stage_stagebundle_enseignant[dateNaissance]": {
                    required: true,
                    minlength: 4

                },
                "stage_stagebundle_enseignant[cin]": {
                    required: true,
                    number: true,
                    minlength: 8,
                    maxlength: 8

                },
                "stage_stagebundle_enseignant[telephonne]": {
                    required: true,
                    number: true,
                    minlength: 8,
                    maxlength: 8


                }

            },
            messages: {
                "stage_stagebundle_enseignant[nom]": {
                    required: "Le 'NOM' n'est pas valide",
                    minlength: "Longueur minimale du 'NOM' incorrecte",
                    maxlength: "Longueur maximale du 'NOM' incorrecte"
                },
                "stage_stagebundle_enseignant[prenom]": {
                    required: "Le 'PRENOM' n'est pas valide",
                    minlength: "Longueur minimale du 'PRENOM' incorrecte",
                    maxlength: "Longueur maximale du 'PRENOM' incorrecte"
                },
                "stage_stagebundle_enseignant[dateNaissance]": {
                    required: "Le 'DATE DE NAISSANCE' est invalide"


                },
                "stage_stagebundle_enseignant[cin]": {
                    number: "Le 'N°CIN' est numerique",
                    required: "Le 'N°CIN' n'est pas valide",
                    minlength: "Longueur minimale du 'N°CIN' incorrecte",
                    maxlength: "Longueur maximale du 'N°CIN' incorrecte"


                },
                "stage_stagebundle_enseignant[telephonne]": {
                    number: "Le 'N°TELEPHONE' est numerique",
                    required: "Le 'N°TELEPHONE' n'est pas valide",
                    minlength: "Longueur minimale du 'N°TELEPHONE' incorrecte",
                    maxlength: "Longueur maximale du 'N°TELEPHONE' incorrecte"
                }
            }
        })

        $('#stage_stagebundle_enseignant_dateNaissance').datetimepicker({
            pickTime: false,
            language: "fr-FR"
        })
        resetForm()


        function resetForm() {
            $('#form-enseignant input').val('')
        }
    </script>
{% endblock %}